<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@page import="com.lovo.bbs.vo.*,java.util.*"%>

<%
	int forumid = Integer.parseInt(request.getParameter("fid"));//论坛id
	ArrayList<TopicVo> topList = (ArrayList<TopicVo>) request
			.getAttribute("topList");//主题列表
	ArrayList<TopicVo> topicList = (ArrayList<TopicVo>) request
			.getAttribute("topicList");//置顶主题列表
	HashMap<Integer, ForumVo> forumMap = (HashMap<Integer, ForumVo>) request
			.getAttribute("forumMap");//论坛容器
	ForumVo thisForum = (ForumVo) forumMap.get(forumid);//当前论坛对象
	ForumStatVo forumInfo = (ForumStatVo)request.getAttribute("forumInfo");//网站杂项信息
	
	int topicNum = (Integer) request.getAttribute("topicNum");//主题数
	int queryPage = (Integer) request.getAttribute("queryPage");//请求页
	int pageNum = (topicNum % 20 == 0) ? (topicNum /20)
			: (topicNum / 20 + 1);//页数
	Iterator<TopicVo>  it, it1, it2;
	
	LoginVo loginvo = (LoginVo) session.getAttribute("loginvo");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title><%=thisForum.getForumName()%>-<%=forumInfo.getSiteName() %></title>
		<meta name="description"
			content="<%=thisForum.getForumName()%>" />
		<meta name="keywords"
			content="<%=thisForum.getForumName()%>" />

		<link href="css/style.css" type="text/css" rel=stylesheet />
		<link href="css/menu.css" type="text/css" rel=stylesheet />
		<link href="css/common.css" type="text/css" rel="stylesheet" />

		<script type="text/javascript" src="js/vbulletin_global.js"></script>
		<script type="text/javascript" src="js/vbulletin_menu.js"></script>
		<script type="text/javascript" src="fckeditor/fckeditor.js"></script>
		<script type="text/javascript" src="js/wbs_common.js"></script>
		<script type="text/javascript" src="js/wbs_ajax.js"></script>
		<script type="text/javascript" src="js/wbs_dragdrop.js"></script>
		<script type="text/javascript" src="js/wbs_popup.js"></script>
		<script type="text/javascript">
			var IMGDIR_MISC = "";
		</script>

	</head>
	<body>
		<div id="overlay"></div>
		<div id=popLayer style="position: absolute; z-index: 101"
			class=cPopText></div>
		<table width="100%" align="center" cellpadding="0" cellspacing="1"
			class="CommonNavigation_OuterTableCSS">
			<tr>
				<td>
					<table width="100%" cellpadding="9" cellspacing="0">
						<tr>
							<td class="CommonNavigation_InnerTableFooterCSS">
								<table width="100%" cellpadding="0" cellspacing="0" board="1">
									<tr>
									
									
									    <!--登录状态----------------------------------------------------------------->
										<td class="SmallTxt">
											<%
												if (session.getAttribute("loginvo") == null) {
											%>
											<font class="SmallGrayText">欢迎: <b>游客</b> </font>
											<font class="SmlLinks">( </font><a href="javascript:void(0)"
												onclick="openLogin()">登陆</a><font class="SmlLinks"> |
											</font><a href="javascript:void(0)" onclick="openRegister()">注册</a><font
												class="SmlLinks"> )</font>
												
												
											<!--注册窗口----------------------------------------------------------------->	
											<%@include file="include/regWindow.html"%>

											<%
												} else {
													loginvo = (LoginVo) session.getAttribute("loginvo");
											%>
											欢迎:
											<em id="logedusername" value="<%=loginvo.getUserName()%>">
											   <a href="userinfo.jsp?username=<%=loginvo.getUserName()%>"><%=loginvo.getUserName()%></a>
											</em>
											<font class="SmlLinks">( </font><a href="javascript:void(0)"	 onclick="logout()">退出</a><font
												class="SmlLinks"><font class="SmlLinks"> )</font>&nbsp;&nbsp;
												<a class="FunctionDesk" href="control/control.jsp?username=<%=loginvo.getUserName()%>">控制面板</a>
												<%
													}
												%> </font>
										</td>
									</tr>
								</table>
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
		<font size="1"><br> </font>
		<font size="1"><br> </font>
		
		
		<!--导航栏----------------------------------------------------------------->
		<table width="100%" cellpadding="0" cellspacing="1"
			class="BreadCrumb_OuterTableCSS">
			<tr>
				<td>
					<table width="100%" cellpadding="9" cellspacing="0"
						class="BreadCrumb_InnerTableCSS">
						<tr>
							<td align="left">
								<a title="返回首页" class="SmlBoldLinks" href="index.jsp"><%=forumInfo.getSiteName() %></a>
								<font class="BreadCrumb_NavSeperator">&#187;</font>
								<a><%=thisForum.getForumName()%>></a>
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
		
		
		
		<font size="1"><br> </font>
		<font size="1"><br> </font>
		
		<!--页码----------------------------------------------------------------->
		<table width="100%" cellpadding="0" cellspacing="0">
			<tr>
				<td id="content_bar" align="left">
					<a class="content_total"><%=topicNum%>个主题 , 第<%=queryPage%>页 总<%=pageNum%>页</a>
					<% for (int i = 1; i <= pageNum; i++) {
						if (i == queryPage) {
					%>
					<a class="content_pasges_c"><%=i%></a>
					<%} else { %>
					<a class="content_pasges_a"
						href="forum.jsp?fid=<%=forumid%>&page=<%=i%>"><%=i%></a>
					<%}	}%>
				</td>
				
				<!--发表主题按钮----------------------------------------------------------------->
				<td width="30%" align="right">
					<input class="input_btn" type="button" value="发表主题" <%if (loginvo!=null){%>
						onclick="openNewTopic()" <%}else{%> onclick="openErrorLogin()"
						<%}%> />
				</td>
			</tr>
		</table>
		<font size="1"><br> </font>
		
		
		<table class="forum_out" width="100%" border="0" cellpadding="0"
			cellspacing="0">
			<tr>
				<td>
					<table border="0" width="100%" cellpadding="5" cellspacing="0">
						<tr>
						
						    <!--工具栏----------------------------------------------------------------->
							<td class="board" colspan="7" align="center">
								<%=thisForum.getForumName()%>&nbsp;&nbsp;
								<a class="smalltext" id="forumtools"><b>工具栏</b> </a>
								<script type="text/javascript"> vbmenu_register("forumtools"); </script>
								<div class="vbmenu_popup" id="forumtools_menu"
									style="display: none">
									<table cellpadding="4" cellspacing="1" border="0">
										<tr>
											<td class="vbmenu_option" align="center">
												<a href="search.jsp?cond=localbest&fid=<%=thisForum.getForumID()%>">本版精华</a>
											</td>
										</tr>
										<tr>
											<td class="vbmenu_option" align="center">
												<a href="search.jsp?cond=localhot&fid=<%=thisForum.getForumID()%>">本版热帖</a>
											</td>
										</tr>
										<tr>
											<td class="vbmenu_option" align="center">
												<a
													href="javascript:window.external.AddFavorite('', 'MyBBS Lovo33.5')">收藏本版</a>
											</td>
										</tr>
									</table>
								</div>
							</td>
						</tr>
						<tr>
							<td class="forumcell_read" style="width: 6%">
								&nbsp;
							</td>
							<td class="forumcell_read" style="width: 50%;">
								主题
							</td>
							<td class="forumcell_read" align="center" style="width: 14%;">
								发表人
							</td>
							<td class="forumcell_read" align="center" style="width: 6%;">
								回复数
							</td>
							<td class="forumcell_read" align="center" style="width: 6%;">
								查看数
							</td>
							<td class="forumcell_read" align="center" style="width: 18%;">
								最后回复
							</td>
						</tr>
						<%  if (queryPage == 1) {
						 %>
						 
						 <!--置顶区----------------------------------------------------------------->
						<tr>
							<td class="forumcell_button" colspan="7">
								<font class="SmallBoldGrayText">置顶区</font>
							</td>
						</tr>
						<%it1 = topList.iterator();
								if (it1 != null) {
									while (it1.hasNext()) {
								TopicVo topData = it1.next();
						%>
						<tr onMouseOver="this.style.backgroundColor='#F5FBFF'"
							onMouseOut="this.style.backgroundColor='#FFFFFF'">
							<td class="topiccell_button" align="center"
								style="padding-left: 10px">
								<img align="left" <%if(topData.getPostNum()>10){%>
									src="images/topic_hot.gif" <%}else{%> src="images/topic.gif"
									<%}%> border="0" />
							</td>
							<td class="forumcell_button" valign="middle">
								<table width="100%" cellspacing="0" border="0" cellpadding="0">
									<tr>
										<td>
											<a
												href="<%if(true){%>topic.jsp?tid=<%=topData.getTopicid()%>&backpage=<%=queryPage%><%}else{%>javascript:openErrorLogin();<%}%>"><font
												class="<%if(topData.isHighlight()){%>HighLight<%}else{%>smalltext<%}%>"><%=topData.getTopicTitle()%>
													</font> </a>
											<%
											        int replypage = topData.getPostNum() / 20;
													if (replypage >= 1) {
											%>
											<img src="images/multipage.gif" align="middle" border="0" />
											<%for (int i = 0; i <= replypage; i++) {%>
											<a
												href="<%if(true){%>topic.jsp?tid=<%=topData.getTopicid()%>&page=<%=i + 1%><%}else{%>javascript:openErrorLogin();<%}%>"><%=i + 1%></a>
											<%}	}%>
										</td>
										<td align="right">
											<img src="images/topic_top.gif" align="middle" alt="置顶"
												border="0" />
											<%if (topData.isBest()) {%><img src="images/best.gif"
												align="absmiddle" alt="精华" border="0" />
											<%}%>
											<%if (topData.isAttach() ) {%><img src="images/attach.gif"
												align="absmiddle" alt="附件" border="0" />
											<%}%>
										</td>
									</tr>
								</table>
							</td>
							<td class="topiccell_button" align="center">
								<font class="smalltext"><a
									href="userinfo.jsp?username=<%=topData.getAuthorname()%>"><%=topData.getAuthorname()%></a>
								</font>
								<br>
								<font style="font: 12px"><%=topData.getTopicDate()%></font>
							</td>
							<td class="topiccell_button" align="center">
								<font class="smalltext"><%=topData.getPostNum()%></font>
							</td>
							<td class="topiccell_button" align="center">
								<font class="smalltext"><%=topData.getHits()%></font>
							</td>
							<td class="forumcell_button" align="center"
								style="line-height: normal;">
								<font class="smalltext"> <a
									href="<%if(true){%>topic.jsp?tid=<%=topData.getTopicid()%>&backpage=<%=queryPage%>&end=1<%}else{%>javascript:openErrorLogin();<%}%>"><%=topData.getLastPostDate()%></a>
									<br> 发表人: <a
									href="<%if(true){%>topic.jsp?tid=<%=topData.getTopicid()%>&backpage=<%=queryPage%>&end=1<%}else{%>javascript:openErrorLogin();<%}%>"><%=topData.getLastPostAuthor()%></a>
								</font>
							</td>
						</tr>
                        <%}}}%>
                        
                        
                        <!--论坛区----------------------------------------------------------------->
						<tr>
							<td class="forumcell_button" colspan="7">
								<font class="SmallBoldGrayText">论坛区</font>
							</td>
						</tr>
						<%it = topicList.iterator();
							if (it != null) {
								while (it.hasNext()) {
									TopicVo TopicData = it.next();
									if(TopicData.isTop()){
									   continue;
									}
						%>
						<tr onMouseOver="this.style.backgroundColor='#F5FBFF'" onMouseOut="this.style.backgroundColor='#FFFFFF'">
							<td class="forumcell_button" align="center" style="padding-left:10px">
								<img align="left"<%if(TopicData.getPostNum()>10){%>src="images/topic_hot.gif"<%}else{%>src="images/topic.gif"<%}%> border="0" />
							</td>
							<td class="forumcell_button" valign="middle">
								<table width="100%" cellspacing="0" border="0" cellpadding="0">
									<tr>
										<td>
											<a href="<%if(true){%>topic.jsp?tid=<%=TopicData.getTopicid()%>&backpage=<%=queryPage%><%}else{%>javascript:openErrorLogin();<%}%>"><font class="<%if(TopicData.isHighlight()){%>HighLight<%}else{%>smalltext<%}%>"><%=TopicData.getTopicTitle()%>&nbsp;</font></a>
											<%if(TopicData.getPostNum()>20&&TopicData.getHits()>200){%><img src="images/hot.gif" align="middle" alt="热帖" border="0" />&nbsp;&nbsp;<%}%>
											<%int replypage = (TopicData.getPostNum() / 20);
														if (replypage >= 1) {
											%>
											<img src="images/multipage.gif" align="middle" border="0" />
											<%for (int i = 0; i <= replypage; i++) {%>
											<a href="<%if(true){%>topic.jsp?tid=<%=TopicData.getTopicid()%>&page=<%=i + 1%><%}else{%>javascript:openErrorLogin();<%}%>"><%=i + 1%></a>
											<%}	}%>
										</td>
										<td align="right">
											<%if (TopicData.isBest()) {%><img src="images/best.gif" align="middle" alt="精华" border="0" /><%}%>
											<%if (TopicData.isAttach()) {%><img src="images/attach.gif" align="middle" alt="附件"	border="0" /><%}%>
										</td>
									</tr>
								</table>
							</td>
							<td class="topiccell_button" align="center">
								<font class="smalltext"><a href="userinfo.jsp?username=<%=TopicData.getAuthorname()%>"><%=TopicData.getAuthorname()%></a> </font>
								<br>
								<font style="font:12px"><%=TopicData.getTopicDate()%></font>
							</td>
							<td class="forumcell_button" align="center">
								<font class="smalltext"><%=TopicData.getPostNum()%></font>
							</td>
							<td class="forumcell_button" align="center">
								<font class="smalltext"><%=TopicData.getHits()%></font>
							</td>
							<td class="forumcell_button" align="center"	style="line-height:normal;">
								<font class="smalltext"> 
									<a href="<%if(true){%>topic.jsp?tid=<%=TopicData.getTopicid()%>&backpage=<%=queryPage%>&end=1<%}else{%>javascript:openErrorLogin();<%}%>"><%=TopicData.getLastPostDate()%></a> <br>
									发表人: <a href="<%if(true){%>topic.jsp?tid=<%=TopicData.getTopicid()%>&backpage=<%=queryPage%>&end=1<%}else{%>javascript:openErrorLogin();<%}%>"><%=TopicData.getLastPostAuthor()%>	</a>
								</font>
							</td>
						</tr>
						<%}}%>
					</table>
				</td>
			</tr>
		</table>
		<font size="1"><br></font>
		
		<!--页码----------------------------------------------------------------->
		<table width="100%" cellpadding="0" cellspacing="0">
			<tr>
				<td id="content_bar" align="left">
					<a class="content_total"><%=topicNum%>个主题 , 第<%=queryPage%>页	总<%=pageNum%>页</a>
					<% for (int i = 1; i <= pageNum; i++) {
						if (i == queryPage) {
					%>
					<a class="content_pasges_c"><%=i%></a>
					<%} else { %>
					<a class="content_pasges_a" href="forum.jsp?fid=<%=forumid%>&page=<%=i%>"><%=i%></a>
					<%}	}%>
				</td>
				<td width="30%" align="right">
					<input class="input_btn" type="button" value="发表主题"<%if (loginvo!=null){%> onclick="openNewTopic()"<%}else{%> onclick="openErrorLogin()"<%}%>/>
				</td>
			</tr>
		</table>
		
		
		<font size="1"><br></font>
		<font size="1"><br></font>
		<font size="1"><br></font>
		
		    
		<!--页脚----------------------------------------------------------------->
		<%@include file="include/copyright.html"%>

		<!-- 发表主题页面 -------------------------------------------------------->
		<form method="POST" name="newtopic" action="NewTopicServlet">
		    <%@ include file="include/newtopic.html"%>
			<input type="hidden" name="forumid" value="<%=thisForum.getForumID() %>">
			<%if (loginvo!=null){%>
			      <input type="hidden" name="topicauthorname" value="<%=loginvo.getUserName() %>">
			<%} %>
		</form>
		
		<!--登录窗口 ----------------------------------------------------------------->
		<%@include file="include/loginWindow.html"%>
		<script type="text/javascript">
				vBulletin_init();
		</script>
	</body>
</html>